package com.musemun.pojo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.converters.bytearray.BoxingByteArrayImageConverter;
import com.alibaba.excel.converters.bytearray.ByteArrayImageConverter;
import com.alibaba.excel.converters.file.FileImageConverter;
import com.alibaba.excel.converters.inputstream.InputStreamImageConverter;
import com.alibaba.excel.converters.string.StringImageConverter;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.musemun.contants.StaticVariable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.experimental.Accessors;
import org.apache.ibatis.javassist.bytecode.ByteArray;

import javax.imageio.stream.ImageInputStream;
import java.io.InputStream;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

@EqualsAndHashCode(callSuper = false)
@Data
@ContentRowHeight(140)
public class ExcelCrifo implements Serializable{


    public ExcelCrifo(URL crPic, Date crSaveDate) {
        this.crPic = crPic;
        this.crSaveDate = crSaveDate;
    }


    @ExcelProperty("")
    @ColumnWidth(10)
    @ApiModelProperty(value = "文物编号")
    private Long crNo;

    @NonNull
    @ColumnWidth(25)
    @ExcelProperty(value = "图片")
    @ApiModelProperty(value = "文物图片")
    private URL crPic;

    @ColumnWidth(25)
    @ExcelProperty(value = "二维码图片")
    @ApiModelProperty(value = "二维码")
    private URL crTwoImage;

    @ColumnWidth(15)
    @ExcelProperty("名称")
    @ApiModelProperty(value = "文物名字")
    private String crName;

    @ColumnWidth(9)
    @ExcelProperty("年代")
    @ApiModelProperty(value = "年代")
    private String crYear;

    @ColumnWidth(9)
    @ExcelProperty("年号")
    @ApiModelProperty(value = "年号")
    private String crYearNum;

    @ColumnWidth(9)
    @ExcelProperty("来源")
    @ApiModelProperty(value = "来源")
    @TableField("crSource")
    private String crSource;

    @ColumnWidth(15)
    @ExcelProperty("器型/材质")
    @ApiModelProperty(value = "器型")
    private String crType;

    @ColumnWidth(30)
    @ExcelProperty("收储日期")
    @ApiModelProperty(value = "收储日期")
    private Date crSaveDate;

    @ColumnWidth(9)
    @ExcelProperty("状态")
    @ApiModelProperty(value = "状态")
    private String crState;

    @ColumnWidth(9)
    @ExcelProperty("收储仓库")
    @ApiModelProperty(value = "收储仓库")
    private String crWarehouse;

    @ColumnWidth(9)
    @ExcelProperty("收储地点")
    @ApiModelProperty(value = "收储地点")

    private String crAddr;

    @ColumnWidth(9)
    @ExcelProperty("数量")
    @ApiModelProperty(value = "数量")
    private Integer crNum;

    @ColumnWidth(9)
    @ExcelProperty("尺寸")
    @ApiModelProperty(value = "尺寸")
    private String crSize;

    @ColumnWidth(9)
    @ExcelProperty("入馆价值")
    @ApiModelProperty(value = "入馆价值")
    private String crInValue;

    @ColumnWidth(9)
    @ExcelProperty("离馆价值")
    @ApiModelProperty(value = "离馆价值")
    private String crOutValue;

    @ColumnWidth(30)
    @ExcelProperty("录入日期")
    @ApiModelProperty(value = "录入日期")
    private Date crRecordDate;

    @ExcelIgnore
    @ApiModelProperty(value = "是否清点")
    private Boolean crCheck;

    public ExcelCrifo(Crifo crifo) throws MalformedURLException {
        this.crNo = crifo.getCrNo();
        this.crPic = new URL(StaticVariable.URL +crifo.getCrPic());
        this.crTwoImage=new URL(StaticVariable.URL+"/two_dimensional_code/generator_image/"+crifo.getCrNo());
        this.crName = crifo.getCrName();
        this.crYear = crifo.getCrYear();
        this.crYearNum = crifo.getCrYearNum();
        this.crSource = crifo.getCrSource();
        this.crType = crifo.getCrType();
        this.crSaveDate = crifo.getCrSaveDate();
        this.crState = crifo.getCrState();
        this.crWarehouse = crifo.getCrWarehouse();
        this.crAddr = crifo.getCrAddr();
        this.crNum = crifo.getCrNum();
        this.crSize = crifo.getCrSize();
        this.crInValue = crifo.getCrInValue();
        this.crOutValue = crifo.getCrOutValue();
        this.crRecordDate = crifo.getCrRecordDate();
        this.crCheck = crifo.getCrCheck();
    }
}
